package weifei.wx.community.service;


import com.mybatisflex.core.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import weifei.wx.community.entity.TieComment;
import weifei.wx.community.entity.dto.TieCommentDTO;
import weifei.wx.community.entity.dto.UserDTO;
import weifei.wx.community.mapper.TieCommentMapper;

@Service
public class TieCommentService
{
    @Autowired
    private UserService userService;

    @Autowired
    private TieCommentMapper tieCommentMapper;


    public TieCommentDTO getTieCommentByID(Long id)
    {
        QueryWrapper queryWrapper = QueryWrapper.create()
                .where("id = ?", id);
        final TieComment t = this.tieCommentMapper.selectOneByQuery(queryWrapper);
        if (t == null)
            return null;

        final UserDTO userDTO = this.userService.getUserByID(t.getUserId());
        return new TieCommentDTO(userDTO, t);
    }
}


